<?php
require_once 'config/database.php';
session_start();

// 检查是否是管理员
if (!isset($_SESSION['user_id']) || $_SESSION['role'] != 'admin') {
    echo json_encode(['success' => false, 'message' => '权限不足']);
    exit;
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $id = (int)$_POST['id'];
    $is_number_changed = $conn->real_escape_string($_POST['is_number_changed']);
    
    $sql = "UPDATE production_details SET is_number_changed = '$is_number_changed' WHERE id = $id";
    
    if ($conn->query($sql)) {
        echo json_encode(['success' => true]);
    } else {
        echo json_encode(['success' => false, 'message' => $conn->error]);
    }
} else {
    echo json_encode(['success' => false, 'message' => '无效的请求方法']);
} 